import { request } from './request'

export function getArticlesItem (channel_id, pre_timestamp) {
  return request({
    method: 'get',
    url: '/v1_0/articles',
    params: {
      channel_id: channel_id,
      timestamp: pre_timestamp || +new Date() + ''
    }
  })
}

export function getArticlesInfo (id) {
  return request({
    method: 'get',
    url: '/v1_0/articles/' + id
  })
}

export function setUserFollow (target) {
  return request({
    method: 'post',
    url: '/v1_0/user/followings',
    data: {
      target
    }
  })
}

export function deleteUserFollow (target) {
  return request({
    method: 'DELETE',
    url: '/v1_0/user/followings/' + target
  })
}

export function setLoveUser (target) {
  return request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
      target
    }
  })
}

export function deleteLoveUser (target) {
  return request({
    method: 'DELETE',
    url: '/v1_0/article/likings/' + target
  })
}

export function getComments (type, source, offset, limit) {
  return request({
    method: 'get',
    url: '/v1_0/comments',
    params: {
      type,
      source,
      offset,
      limit
    }
  })
}

export function setCommentslike (target) {
  return request({
    method: 'post',
    url: '/v1_0/comment/likings',
    data: {
      target
    }
  })
}

export function deleteCommentslike (target) {
  return request({
    method: 'DELETE',
    url: '/v1_0/comment/likings/' + target
  })
}

export function showComments (target, content) {
  return request({
    method: 'post',
    url: '/v1_0/comments',
    data: {
      target,
      content
    }
  })
}

export function notInterestedIn (target) {
  return request({
    method: 'post',
    url: '/v1_0/article/dislikes',
    data: {
      target
    }
  })
}

export function reports (target, type, remark) {
  return request({
    method: 'post',
    url: '/v1_0/article/reports',
    data: {
      target,
      type,
      remark
    }
  })
}

export function updatechannel (channels) {
  return request({
    method: 'put',
    url: '/v1_0/user/channels',
    data: {
      channels
    }
  })
}
